# -*-coding:utf-8 -*-
from django.shortcuts import render
from org.api.serializers import *
from org.models import *
from rest_framework import generics, viewsets
from rest_framework import renderers
from core.api.views import HtmlModelViewSet, DynamicFieldsViewMixin


class DepartmentAPIView(DynamicFieldsViewMixin, viewsets.ModelViewSet):
    """
    部门管理
    """
    queryset = Department.objects.all()
    serializer_class = DepartmentSerializer
    #permission_classes = (IsAdminUser,)
    ordering_fields = ('spinyin',)
    search_fields = ('name',)
    filter_fields = ('parent',)


class PersonAPIView(DynamicFieldsViewMixin, viewsets.ModelViewSet):
    """
    人员
    """
    queryset = Person.objects.all()
    serializer_class = PersonnelSerializer
    #permission_classes = (IsAdminUser,)
    ordering_fields = ('spinyin',)
    search_fields = ('name',)
    filter_fields = ('department',)
